﻿using RBAC.Repository.RabbitImpl;
using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class PackagingService : IPackagingService
    {
        private readonly IPackagingRepository _packagingRepository;
        public PackagingService(IPackagingRepository packagingRepository)
        {
            _packagingRepository = packagingRepository;
        }
        /// <summary>
        /// 添加包材信息
        /// </summary>
        /// <param name="packaging"></param>
        /// <returns></returns>
        public async Task<int> CreatePackaging(Packaging packaging)
        {
           return await _packagingRepository.AddAsync(packaging);
        }
        /// <summary>
        /// 反填包材信息
        /// </summary>
        /// <param name="Packagingid"></param>
        /// <returns></returns>
        public async Task<List<Packaging>> GetPackagingBy(string bath)
        {
            return await _packagingRepository.GetAsync(d => d.PackagingBatch == bath);
        }
        /// <summary>
        /// 显示包材信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        public async Task<List<Packaging>> GetPackagingList(int tid)
        {
            return await _packagingRepository.GetAsync(d => d.TraceabilityId==tid);
        }
        /// <summary>
        /// 修改包材信息
        /// </summary>
        /// <param name="packaging"></param>
        /// <returns></returns>
        public async Task<int> UpdatePackaging(Packaging packaging)
        {
           return await _packagingRepository.UpdateAsync(packaging);
        }
    }
}
